package com.amumu.drama.common.modules.sumapay.tools;


import cn.hutool.json.JSONNull;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class JsonToolUtil {
    /**
     * ����json��ʽ�ַ�����ת��ΪMap
     *
     * @param jsonString
     * @return Map
     */
    public static Map<String, Object> transJsonToMap(String jsonString) {
        JSONObject jsonObject = JSONUtil.parseObj(jsonString);
        Iterator<?> keyIter = jsonObject.keySet().iterator();
        String key;
        Object value;
        Map<String, Object> valueMap = new HashMap<String, Object>();

        while (keyIter.hasNext()) {
            key = (String) keyIter.next();
            value = jsonObject.get(key);
            if (!(value instanceof JSONNull)) {
                valueMap.put(key, value);
            }
        }
        return valueMap;
    }
}
